package com.sky.mapper;

import com.sky.aop.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    /**
     * 新增菜品
     * @param dish
     * @return
     */
    @AutoFill(OperationType.INSERT)
    Integer insertDish(Dish dish);

    /**
     * 分页查询
     * @param dishPageQueryDTO
     * @return
     */
    List<DishVO> selectByPage(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 批量删除
     * @param ids
     * @return
     */
    Integer deleteByIds(List<Long> ids);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish selectById(Long id);

    /**
     * 更新菜品信息
     * @param dish
     * @return
     */
    Integer updateById(Dish dish);

    /**
     * 根据分类id查询
     * @param dish
     * @return
     */
    @Select("select * from dish where category_id = #{categoryId}")
    List<DishVO> selectByCategoryId(Dish dish);

    @Select("select * from dish where category_id  = #{categoryId}")
    List<Dish> list(Dish dish);
}
